//
//  TabBtn.swift
//  Casecord
//
//  Created by baozi on 2024/1/5.
//

import SwiftUI
enum SideItemType: String {
    case about
    case logout
    case help
    case home
    case security
}
struct TabBtn: View {
    var image: String
    var title: SideItemType
    @Binding var selectTab: SideItemType
    var animation: Namespace.ID
    var action: TabActionCallback
    var body: some View {
        Button(action: {
            withAnimation(.spring()){
                selectTab = title
            }
            action(selectTab)
        }, label: {
            HStack(spacing: 15) {
                Image(systemName: image)
                    .font(.title)
                    .frame(width: 30)
                Text(title.rawValue.capitalized)
                    .fontWeight(.semibold)
            }
            .foregroundColor(selectTab == title ? Theme.color.primaryBackgroundColor : .white)
            .paddingVerticol(12)
            .paddingHorizontal(10)
            .frame(maxWidth: Screen.width - 170,  alignment: .leading)
            .background(
                ZStack {
                    if selectTab == title {
                        Color.white
                            .clipShape(
                                .rect(cornerRadii: RectangleCornerRadii(bottomTrailing: 5, topTrailing: 5))
                            )
                            .matchedGeometryEffect(id: "TAB", in: animation)
                    }
                }
            )
        })
    }
}

